package cn.com.sealevel.util;

import cn.com.sealevel.bean.CborBean;
import com.upokecenter.cbor.CBORObject;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import org.apache.commons.lang3.ArrayUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/* loaded from: netty-mqtt-client-1.0.0.jar:cn/com/sealevel/util/CborUtil.class */
public class CborUtil {
    private static final Logger logger = LoggerFactory.getLogger(CborUtil.class);
    private static final Random random = new Random();
    private static SimpleDateFormat YYMMDD = new SimpleDateFormat("yyMMdd");
    private static SimpleDateFormat HHMMSS = new SimpleDateFormat("HHmmss.SSS");

    public static String decodeCbor(byte[] data) {
        try {
            ByteBuffer buf = ByteBuffer.wrap(data);
            String cborValue1 = getCborValue(buf);
            String cborValue2 = getCborValue(buf);
            byte[] remainBytes = new byte[buf.remaining()];
            buf.get(remainBytes);
            if (remainBytes.length <= 0) {
                return DataUtil.getHexStringByBytes(data);
            }
            return cborValue1 + "," + cborValue2 + "," + CBORObject.DecodeFromBytes(remainBytes).toString();
        } catch (Exception e) {
            logger.error("转换CBOR格式数据出错！" + DataUtil.getHexStringByBytes(data), e);
            return DataUtil.getHexStringByBytes(data);
        }
    }

    public static String getCborValue(ByteBuffer buf) {
        BigDecimal temp = new BigDecimal(buf.get() & 255);
        if (temp.intValue() >= 24) {
            if (temp.intValue() == 24) {
                temp = new BigDecimal(buf.get() & 255);
            } else if (temp.intValue() == 25) {
                temp = new BigDecimal(buf.getShort() & 65535);
            } else {
                temp = new BigDecimal(0);
            }
        }
        return temp.toString();
    }

    public static BigDecimal getUnsignedLong(long value) {
        if (value >= 0) {
            return new BigDecimal(value);
        }
        return BigDecimal.valueOf(value & Long.MAX_VALUE).add(BigDecimal.valueOf(Long.MAX_VALUE)).add(BigDecimal.valueOf(1L));
    }

    public static CborBean encodeCborData1S() {
        CBORObject cborDataObj6 = CBORObject.NewMap();
        cborDataObj6.Add(4, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(28, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(29, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(30, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(31, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(32, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(33, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(78, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(79, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(80, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(81, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(82, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(83, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(84, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(85, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(86, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(87, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(88, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(89, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(90, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(91, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(92, Integer.valueOf(random.nextInt(2)));
        CBORObject cborDataObj = CBORObject.NewArray();
        cborDataObj.Add(CBORObject.FromObject(System.currentTimeMillis()));
        cborDataObj.Add(cborDataObj6);
        cborDataObj.Add(CBORObject.Null);
        cborDataObj.Add(CBORObject.Null);
        CBORObject cborObj = CBORObject.NewArray();
        cborObj.Add(CBORObject.FromObject(""));
        cborObj.Add(CBORObject.FromObject(2));
        cborObj.Add(cborDataObj);
        CBORObject[] allCborObj = {CBORObject.FromObject(1), CBORObject.FromObject(DataUtil.getSerial()), cborObj};
        byte[] message = ArrayUtils.addAll(ArrayUtils.addAll(allCborObj[0].EncodeToBytes(), allCborObj[1].EncodeToBytes()), allCborObj[2].EncodeToBytes());
        CborBean bean = new CborBean();
        bean.setMessage(message);
        bean.setData(allCborObj[0].toString() + "," + allCborObj[1].toString() + "," + allCborObj[2].toString());
        return bean;
    }

    public static CborBean encodeCborData1Min(String location) {
        CBORObject cborDataObj6 = CBORObject.NewMap();
        cborDataObj6.Add(4, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(28, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(29, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(30, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(31, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(32, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(33, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(78, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(79, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(80, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(81, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(82, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(83, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(84, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(85, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(86, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(87, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(88, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(89, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(90, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(91, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(92, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(1, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(5, Integer.valueOf(random.nextInt(200)));
        cborDataObj6.Add(6, location);
        cborDataObj6.Add(9, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(10, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(11, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(12, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(13, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(14, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(15, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(16, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(17, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(18, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(19, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(20, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(21, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(22, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(23, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(24, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(25, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(26, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(27, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(34, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(35, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(36, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(37, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(38, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(39, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(40, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(41, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(42, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(43, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(44, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(45, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(46, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(47, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(48, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(49, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(50, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(51, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(52, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(53, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(54, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(55, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(56, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(57, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(58, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(59, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(60, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(61, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(62, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(63, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(64, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(65, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(66, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(67, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(68, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(69, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(70, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(71, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(72, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(73, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(74, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(75, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(76, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(77, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(93, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(94, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(95, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(96, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(97, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(98, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(99, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(100, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(101, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(102, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(103, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(104, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(105, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(106, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(107, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(108, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(109, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(110, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(111, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(112, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(113, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(114, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(115, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(116, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(117, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(118, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(119, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(120, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(121, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(122, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(123, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(124, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(125, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(126, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(127, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(128, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(129, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(130, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(131, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(132, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(133, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(134, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(135, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(136, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(137, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(138, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(139, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(140, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(141, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(142, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(143, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(144, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(145, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(146, Integer.valueOf(random.nextInt(2)));
        CBORObject cborDataObj = CBORObject.NewArray();
        cborDataObj.Add(CBORObject.FromObject(System.currentTimeMillis()));
        cborDataObj.Add(cborDataObj6);
        cborDataObj.Add(CBORObject.Null);
        cborDataObj.Add(CBORObject.Null);
        CBORObject cborObj = CBORObject.NewArray();
        cborObj.Add(CBORObject.FromObject(""));
        cborObj.Add(CBORObject.FromObject(2));
        cborObj.Add(cborDataObj);
        CBORObject[] allCborObj = {CBORObject.FromObject(1), CBORObject.FromObject(DataUtil.getSerial()), cborObj};
        byte[] message = ArrayUtils.addAll(ArrayUtils.addAll(allCborObj[0].EncodeToBytes(), allCborObj[1].EncodeToBytes()), allCborObj[2].EncodeToBytes());
        CborBean bean = new CborBean();
        bean.setMessage(message);
        bean.setData(allCborObj[0].toString() + "," + allCborObj[1].toString() + "," + allCborObj[2].toString());
        return bean;
    }

    public static CborBean encodeCborData3Min(String location) {
        CBORObject cborDataObj6 = CBORObject.NewMap();
        cborDataObj6.Add(4, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(28, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(29, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(30, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(31, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(32, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(33, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(78, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(79, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(80, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(81, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(82, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(83, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(84, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(85, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(86, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(87, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(88, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(89, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(90, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(91, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(92, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(1, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(5, Integer.valueOf(random.nextInt(200)));
        cborDataObj6.Add(6, location);
        cborDataObj6.Add(9, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(10, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(11, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(12, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(13, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(14, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(15, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(16, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(17, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(18, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(19, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(20, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(21, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(22, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(23, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(24, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(25, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(26, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(27, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(34, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(35, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(36, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(37, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(38, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(39, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(40, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(41, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(42, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(43, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(44, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(45, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(46, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(47, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(48, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(49, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(50, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(51, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(52, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(53, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(54, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(55, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(56, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(57, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(58, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(59, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(60, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(61, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(62, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(63, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(64, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(65, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(66, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(67, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(68, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(69, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(70, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(71, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(72, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(73, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(74, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(75, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(76, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(77, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(93, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(94, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(95, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(96, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(97, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(98, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(99, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(100, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(101, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(102, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(103, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(104, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(105, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(106, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(107, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(108, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(109, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(110, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(111, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(112, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(113, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(114, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(115, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(116, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(117, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(118, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(119, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(120, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(121, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(122, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(123, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(124, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(125, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(126, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(127, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(128, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(129, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(130, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(131, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(132, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(133, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(134, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(135, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(136, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(137, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(138, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(139, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(140, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(141, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(142, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(143, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(144, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(145, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(146, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(7, Double.valueOf(((double) random.nextInt(20000)) * 0.1d));
        cborDataObj6.Add(8, Double.valueOf(((double) random.nextInt(20000)) * 0.1d));
        CBORObject cborDataObj = CBORObject.NewArray();
        cborDataObj.Add(CBORObject.FromObject(System.currentTimeMillis()));
        cborDataObj.Add(cborDataObj6);
        cborDataObj.Add(CBORObject.Null);
        cborDataObj.Add(CBORObject.Null);
        CBORObject cborObj = CBORObject.NewArray();
        cborObj.Add(CBORObject.FromObject(""));
        cborObj.Add(CBORObject.FromObject(2));
        cborObj.Add(cborDataObj);
        CBORObject[] allCborObj = {CBORObject.FromObject(1), CBORObject.FromObject(DataUtil.getSerial()), cborObj};
        byte[] message = ArrayUtils.addAll(ArrayUtils.addAll(allCborObj[0].EncodeToBytes(), allCborObj[1].EncodeToBytes()), allCborObj[2].EncodeToBytes());
        CborBean bean = new CborBean();
        bean.setMessage(message);
        bean.setData(allCborObj[0].toString() + "," + allCborObj[1].toString() + "," + allCborObj[2].toString());
        return bean;
    }

    public static CborBean encodeCborData30Min(String location) {
        CBORObject cborDataObj6 = CBORObject.NewMap();
        cborDataObj6.Add(4, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(28, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(29, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(30, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(31, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(32, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(33, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(78, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(79, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(80, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(81, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(82, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(83, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(84, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(85, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(86, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(87, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(88, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(89, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(90, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(91, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(92, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(1, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(5, Integer.valueOf(random.nextInt(200)));
        cborDataObj6.Add(6, location);
        cborDataObj6.Add(9, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(10, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(11, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(12, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(13, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(14, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(15, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(16, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(17, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(18, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(19, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(20, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(21, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(22, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(23, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(24, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(25, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(26, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(27, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(34, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(35, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(36, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(37, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(38, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(39, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(40, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(41, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(42, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(43, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(44, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(45, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(46, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(47, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(48, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(49, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(50, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(51, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(52, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(53, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(54, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(55, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(56, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(57, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(58, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(59, Integer.valueOf(random.nextInt(180)));
        cborDataObj6.Add(60, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(61, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(62, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(63, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(64, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(65, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(66, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(67, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(68, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(69, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(70, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(71, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(72, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(73, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(74, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(75, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(76, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(77, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(93, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(94, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(95, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(96, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(97, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(98, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(99, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(100, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(101, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(102, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(103, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(104, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(105, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(106, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(107, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(108, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(109, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(110, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(111, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(112, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(113, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(114, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(115, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(116, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(117, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(118, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(119, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(120, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(121, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(122, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(123, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(124, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(125, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(126, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(127, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(128, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(129, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(130, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(131, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(132, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(133, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(134, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(135, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(136, Integer.valueOf(random.nextInt(100)));
        cborDataObj6.Add(137, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(138, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(139, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(140, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(141, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(142, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(143, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(144, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(145, Integer.valueOf(random.nextInt(2000)));
        cborDataObj6.Add(146, Integer.valueOf(random.nextInt(2)));
        cborDataObj6.Add(7, Double.valueOf(((double) random.nextInt(20000)) * 0.1d));
        cborDataObj6.Add(8, Double.valueOf(((double) random.nextInt(20000)) * 0.1d));
        cborDataObj6.Add(2, 10);
        cborDataObj6.Add(3, 2000);
        CBORObject cborDataObj = CBORObject.NewArray();
        cborDataObj.Add(CBORObject.FromObject(System.currentTimeMillis()));
        cborDataObj.Add(cborDataObj6);
        cborDataObj.Add(CBORObject.Null);
        cborDataObj.Add(CBORObject.Null);
        CBORObject cborObj = CBORObject.NewArray();
        cborObj.Add(CBORObject.FromObject(""));
        cborObj.Add(CBORObject.FromObject(2));
        cborObj.Add(cborDataObj);
        CBORObject[] allCborObj = {CBORObject.FromObject(1), CBORObject.FromObject(DataUtil.getSerial()), cborObj};
        byte[] message = ArrayUtils.addAll(ArrayUtils.addAll(allCborObj[0].EncodeToBytes(), allCborObj[1].EncodeToBytes()), allCborObj[2].EncodeToBytes());
        CborBean bean = new CborBean();
        bean.setMessage(message);
        bean.setData(allCborObj[0].toString() + "," + allCborObj[1].toString() + "," + allCborObj[2].toString());
        return bean;
    }

    public static byte[] encodeCborData() {
        CBORObject cborDataObj6 = CBORObject.NewMap();
        cborDataObj6.Add("test", 1);
        cborDataObj6.Add(2, Double.valueOf(2.0d));
        CBORObject cborDataObj = CBORObject.NewArray();
        cborDataObj.Add(CBORObject.FromObject(System.currentTimeMillis()));
        cborDataObj.Add(cborDataObj6);
        cborDataObj.Add(CBORObject.Null);
        cborDataObj.Add(CBORObject.Null);
        CBORObject cborObj = CBORObject.NewArray();
        cborObj.Add(CBORObject.FromObject(""));
        cborObj.Add(CBORObject.FromObject(2));
        cborObj.Add(cborDataObj);
        CBORObject[] allCborObj = {CBORObject.FromObject(1), CBORObject.FromObject(DataUtil.getSerial()), cborObj};
        for (CBORObject temp : allCborObj) {
            System.out.println(temp.toString());
        }
        return ArrayUtils.addAll(ArrayUtils.addAll(allCborObj[0].EncodeToBytes(), allCborObj[1].EncodeToBytes()), allCborObj[2].EncodeToBytes());
    }

    public static void decodeCborData(byte[] data) {
        CBORObject[] allCborObj = CBORObject.DecodeSequenceFromBytes(data);
        int stpVersion = allCborObj[0].AsInt32();
        int serial = allCborObj[1].AsInt32();
        String equipmentId = allCborObj[2].get(0).AsString();
        int secondVersion = allCborObj[2].get(1).AsInt32();
        long timestamp = allCborObj[2].get(2).get(0).AsInt64Value();
        CBORObject cborDataObj6 = allCborObj[2].get(2).get(1);
        System.out.println("stpVersion:" + stpVersion);
        System.out.println("serial:" + serial);
        System.out.println("equipmentId:" + equipmentId);
        System.out.println("secondVersion:" + secondVersion);
        System.out.println("timestamp:" + timestamp);
        System.out.println("cborDataObj6:" + cborDataObj6.toString());
    }

    private static String getLocation(double lon, double lat) {
        Date date = new Date();
        return "$GPRMC," + HHMMSS.format(date) + ",A," + lat + ",N," + lon + ",E,0.000,74.11," + YYMMDD.format(date) + ",,,D*49";
    }

    public static void main(String[] args) {
        System.out.println(decodeCbor(DataUtil.getBytesByHexString("0101836002841B00000187FA4E1967F6F6F6")));
        for (CBORObject temp : CBORObject.DecodeSequenceFromBytes(DataUtil.getBytesByHexString("0101836002841B00000187FA4E1967F6F6F6"))) {
            System.out.println(temp.toString());
        }
        byte[] data = encodeCborData1Min(getLocation(12012.1314d, 2312.1314d)).getMessage();
        System.out.println(DataUtil.getHexStringByBytes(data));
        decodeCborData(data);
    }
}
